﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.AndonManagement;
using Digitalmes.Model.EquipmentManagement;

namespace Digitalmes.Model.AndonManagement
{
    /// <summary>
    /// 安灯站
    /// </summary>
	[Table("AndonStation")]

    [Display(Name = "_Model.AndonStation")]
    public class AndonStation : BasePoco,IPersistPoco,ITenant
    {
        [Key]
        [Display(Name = "_Model._AndonStation._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._AndonStation._DeviceUser")]
        [Comment("设备名称")]
        [NotMapped]
        public FrameworkUser DeviceUser { get; set; }
        [Display(Name = "_Model._AndonStation._DeviceUser")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("设备名称")]
        public string DeviceUserId { get; set; }
        [Display(Name = "_Model._AndonStation._EquipmentId")]
        [Comment("关联设备")]
        public long? EquipmentId { get; set; }


        public Equipment Equipment { get; set; }    

        [Display(Name = "_Model._AndonStation._Name")]
        [Comment("名称")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Name { get; set; }
        [Display(Name = "_Model._AndonStation._Code")]
        [Comment("编号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Code { get; set; }
        [Display(Name = "_Model._AndonStation._Remark")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._AndonStation._IpAddress")]
        [Comment("主机地址")]
        [RegularExpression("(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]", ErrorMessage = "Validate.{0}formaterror")]
        public string IpAddress { get; set; }
        [Display(Name = "_Model._AndonStation._TagId")]
        [Comment("关联变量")]
        public long? TagId { get; set; }
        [Display(Name = "_Model._AndonStation._TagAddress")]
        [Comment("变量地址")]
        public string TagAddress { get; set; }
        [Display(Name = "_Model._IssueRecord._Station")]
        [InverseProperty("Station")]
        public List<IssueRecord> IssueRecord_Station { get; set; }
        [Display(Name = "_Model._AndonStationHeader._Station")]
        [InverseProperty("Station")]
        public List<AndonStationHeader> AndonStationHeader_Station { get; set; }
        [Display(Name = "_Model._AndonStation._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
